package domfarr.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.tapestry5.beaneditor.NonVisual;
import org.apache.tapestry5.beaneditor.Validate;

@Entity
@Table(name="CONTACTS")
@NamedQuery(name="findAll", query="SELECT c FROM Contact c")
public class Contact {

	@NonVisual
	@Id
	@GeneratedValue
	@Column(name="ID")
    private Long id;

	@Validate("required")
	@Column(name="FULL_NAME")
	private String fullName;
	
	@Validate("required")
	@Column(name="PHONE_NUMBER")
	private String phoneNumber;

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}
	
	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}
	
	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}
	
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		
		builder.append("[").append(this.id).append("] | ");
		builder.append("[").append(this.fullName).append("] | ");
		builder.append("[").append(this.phoneNumber).append("]");
		
		return builder.toString();
	}
}
